﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WeChat.ViewModels.Base
{
    public class ViewModelBase : INotifyPropertyChanged, IDisposable
    {
        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

        /// <summary>
        /// 释放资源
        /// </summary>
        public void Dispose()
        {
            this.OnDispose();
        }

        /// <summary>  
        /// 若支持IDisposable，请重写此方法，当被调用Dispose时会执行此方法。  
        /// </summary>  
        protected virtual void OnDispose()
        {
            this.Dispose();
        }
    }
}
